home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1995 #5 & #6 / Amiga Plus CD - 1995 - No. 5 and 6.iso / pd / serien / purity / nr.43 / flushcx / source / flushcx.p < prev    next >
Text File  |  1995-01-07  |  4KB  |  131 lines

  1.  
  2.  
  3. { FlushCX. © by J.Stötzer. All rights reserved, look into docu for more info }
  4.  
  5. program FlushCX;
  6.  
  7. uese Exec,ExecSupport,Intuition;
  8.  
  9. {$incl 'dos.lib','workbench/startup.h','wb.lib','commodities.lib'}
  10.  
  11. const LF = chr(10);
  12.  
  13. type stringTyp = string[500];
  14.  
  15. VAR CPort  : p_MsgPort;
  16.     CItem  : p_AppMenuItem;
  17.     CMsg   : p_AppMessage;
  18.     CCl    : word;
  19.     WBTask : p_Task;
  20.  
  21.     ret    : long;
  22.     ex,err : boolean;
  23.  
  24. {************************************************************************}
  25.  
  26. procedure Terminate;             { Macht allen Commodities das Licht aus }
  27.  
  28. type p_BrokerCopy = ^BrokerCopy;
  29.      BrokerCopy = record
  30.                     bc_Node : Node;
  31.                     bc_Name : string[CBD_NAMELEN];
  32.                     bc_Title: string[CBD_TITLELEN];
  33.                     bc_Descr: string[CBD_DESCRLEN];
  34.                     bc_Task,bc_blabla,bc_blubber : long;
  35.                     bc_Flags: word;
  36.                   end;
  37.  
  38. var BList : p_List;
  39.     CNode : p_Node;
  40.     HNode : p_BrokerCopy;
  41.     ok    : long;
  42.  
  43. begin
  44.   CXBase:=OpenLibrary("commodities.library",37);
  45.   if CXBase<>Nil then begin
  46.     BList:=ptr(AllocVec(SizeOf(List),MEMF_PUBLIC));
  47.     if BList<>Nil then begin
  48.       NewList(BList);
  49.       ok:=CopyBrokerList(BList);
  50.       CNode:=BList^.lh_Head;
  51.       repeat
  52.         HNode:=p_BrokerCopy(ptr(CNode));
  53.         BrokerCommand(HNode^.bc_Name,CXCMD_KILL);
  54.         CNode:=CNode^.ln_Succ;
  55.       until CNode=Nil;
  56.       ok:=FreeBrokerList(BList);
  57.       FreeVec(BList);
  58.     end;
  59.     CloseLibrary(CXBase);
  60.   end;
  61. end;
  62.  
  63. {************************************************************************}
  64.  
  65. function Req(bt:stringTyp;gt:str):long;
  66.  
  67. var ret : long;
  68.     es  : EasyStruct;
  69.  
  70. begin
  71.   es:=EasyStruct(SizeOf(EasyStruct),0,"FlushCX © by Janosh/NEOPLASIA",bt,gt);
  72.   ret:=EasyRequestArgs(Nil,^es,Nil,Nil);
  73.   Req:=ret;
  74. end;
  75.  
  76. {************************************************************************}
  77.  
  78. begin
  79.  
  80.   WBTask:=FindTask('Workbench');
  81.   if WBTask<>Nil then begin
  82.     WorkBenchBase:=OpenLibrary('workbench.library',37);
  83.     if WorkbenchBase<>Nil then begin
  84.       CPort:=CreateMsgPort;
  85.       if CPort<>Nil then begin
  86.         CItem:=AddAppMenuItemA(0,0,'FlushCX',CPort,Nil);
  87.         if CItem<>Nil then begin
  88.           ex:=false;
  89.           repeat
  90.             CMsg:=ptr(WaitPort(CPort));
  91.             CMsg:=ptr(GetMsg(CPort));
  92.             CCl:=CMsg^.am_Type;
  93.             ReplyMsg(ptr(CMsg));
  94.             if CCl=MTYPE_APPMENUITEM then begin
  95.               ret:=Req("Really kill all commodities ??",
  96.                        "Yep!|About|Exit FlushCX|No");
  97.               case ret of
  98.                 1 : Terminate;
  99.                 2 : ret:=Req("FlushCX Version 1.00"+LF+"~~~~~~~~~~~~~~~~~~~~"+LF+LF+
  100.                              "© 12/1994 by Janosh / NEOPLASIA"+LF+LF+
  101.                              "It`s Freeware, look into the"+LF+
  102.                              "documentation for more info."+LF+LF+
  103.                              "To contact me try:"+LF+
  104.                              "   J. Stötzer"+LF+"   An der Hasel 195"+LF+
  105.                              "   D-98527 Suhl / GERMANY"+LF+LF+
  106.                              "E-Mail: stoetzer@rz.tu-ilmenau.de","Really great");
  107.                 3 : if Req("Do you want to quit FlushCX ??","Yho|No way")=1 then
  108.                       ex:=true;
  109.                 4 : ;
  110.                 otherwise
  111.               end;
  112.             end;
  113.           until ex;
  114.           err:=RemoveAppMenuItem(CItem);
  115.         end;
  116.         DeleteMsgPort(CPort);
  117.       end;
  118.       CloseLibrary(WorkbenchBase);
  119.     end;
  120.   end;
  121.  
  122. end.
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.